using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using System;

[Serializable]
public class CharacterInfo{
	public CharacterInfo(AttributeSet attributes, Perks.PerkSet perks){
		//Paso los atributos
        SetAttributeData(ATTRIBUTES.STRENGTH, attributes.GetAttributeDataArray(ATTRIBUTES.STRENGTH));
        SetAttributeData(ATTRIBUTES.DEXTERITY, attributes.GetAttributeDataArray(ATTRIBUTES.DEXTERITY));
        SetAttributeData(ATTRIBUTES.CONSTITUTION, attributes.GetAttributeDataArray(ATTRIBUTES.CONSTITUTION));
        SetAttributeData(ATTRIBUTES.AGILITY, attributes.GetAttributeDataArray(ATTRIBUTES.AGILITY));
        SetAttributeData(ATTRIBUTES.TECHNIQUE, attributes.GetAttributeDataArray(ATTRIBUTES.TECHNIQUE));
		availableAttributePoints = attributes.GetAttributePoints();
        //Paso los sub-atributos
        SetSubAttributeData(SUB_ATTRIBUTES.HIT_POINTS, attributes.GetSubAttributeDataArray(SUB_ATTRIBUTES.HIT_POINTS));
        SetSubAttributeData(SUB_ATTRIBUTES.INVENTORY_SLOTS, attributes.GetSubAttributeDataArray(SUB_ATTRIBUTES.INVENTORY_SLOTS));
        SetSubAttributeData(SUB_ATTRIBUTES.MOVEMENT_SPEED, attributes.GetSubAttributeDataArray(SUB_ATTRIBUTES.MOVEMENT_SPEED));
        SetSubAttributeData(SUB_ATTRIBUTES.NOISE_FACTOR, attributes.GetSubAttributeDataArray(SUB_ATTRIBUTES.NOISE_FACTOR));
        SetSubAttributeData(SUB_ATTRIBUTES.EQUIP_TIME, attributes.GetSubAttributeDataArray(SUB_ATTRIBUTES.EQUIP_TIME));
        SetSubAttributeData(SUB_ATTRIBUTES.STAMINA, attributes.GetSubAttributeDataArray(SUB_ATTRIBUTES.STAMINA));
        //Paso los Perks;
        SetPerks(perks.GetEquippedPerks()); 
		
    }
	//Indice y nombre
	public int index;
	public string charName;
	//Atributos
	public float strengthBase;
	public float strengthBonus;
	public float strengthPercentage;
	public float dexterityBase;
	public float dexterityBonus;
	public float dexterityPercentage;
	public float constitutionBase;
	public float constitutionBonus;
	public float constitutionPercentage;
	public float agilityBase;
	public float agilityBonus;
	public float agilityPercentage;
	public float techniqueBase;
	public float techniqueBonus;
	public float techniquePercentage;
	public int availableAttributePoints;
	public int totalAttributePoints;
	//Sub-Atributos;
	public float inventorySlotsBase;
	public float inventorySlotsBonus;
	public float inventorySlotsPercentage;
	public float inventorySlotsActual;
	public float inventorySlotsMax;
	public float speedBase;
	public float speedBonus;
	public float speedPercentage;
	public float speedActual;
	public float speedMax;
	public float HPBase;
	public float HPBonus;
	public float HPPercentage;
	public float HPActual;
	public float HPMax;
	public float reloadBase;
	public float reloadBonus;
	public float reloadPercentage;
	public float reloadActual;
	public float reloadMax;
	public float noiseBase;
	public float noiseBonus;
	public float noisePercentage;
	public float noiseActual;
	public float noiseMax;
	public float staminaBase;
	public float staminaBonus;
	public float staminaPercentage;
	public float staminaActual;
	public float staminaMax;
	//Perks
	public string[] perks;
/*	public bool allTerrain = false;
	public bool backPackIncrease = false;
	public bool backPackIncreasePlus = false;
	public bool disguise = false;
	public bool doubleStamina = false;
	public bool fastManeuvers = false;
	public bool handgunSilencer = false;
	public bool shotgunProficiency = false;
	public bool silentAssasin = false;
	public bool sniperProficiency = false;
	public bool transportBodies = false;
*/	
	public void SetAttributeData(ATTRIBUTES attribute, float[] data){
		switch(attribute){
		case ATTRIBUTES.STRENGTH:
			strengthBase = data[0];
			strengthBonus = data[1];
			strengthPercentage = data[2];
			break;
		case ATTRIBUTES.DEXTERITY:
			dexterityBase = data[0];
			dexterityBonus = data[1];
			dexterityPercentage = data[2];
			break;
		case ATTRIBUTES.CONSTITUTION :
			constitutionBase = data[0];
			constitutionBonus = data[1];
			constitutionPercentage = data[2];
			break;
		case ATTRIBUTES.AGILITY:
			agilityBase = data[0];
			agilityBonus = data[1];
			agilityPercentage = data[2];
			break;
		case ATTRIBUTES.TECHNIQUE :
			techniqueBase = data[0];
			techniqueBonus = data[1];
			techniquePercentage = data[2];
			break;
		}
	}
	public void SetSubAttributeData(SUB_ATTRIBUTES subAtt, float[] data){
		switch(subAtt){
		case SUB_ATTRIBUTES.HIT_POINTS:
			HPActual = data[0];
			HPBase = data[1];
			HPBonus = data[2];
			HPMax = data[3];
			HPPercentage = data[4];
			break;
		case SUB_ATTRIBUTES.INVENTORY_SLOTS:
			inventorySlotsActual = data[0];
			inventorySlotsBase = data[1];
			inventorySlotsBonus = data[2];
			inventorySlotsMax = data[3];
			inventorySlotsPercentage = data[4];
			break;
		case SUB_ATTRIBUTES.MOVEMENT_SPEED:
			speedActual = data[0];
			speedBase = data[1];
			speedBonus = data[2];
			speedMax = data[3];
			speedPercentage = data[4];
			break;
		case SUB_ATTRIBUTES.NOISE_FACTOR:
			noiseActual = data[0];
			noiseBase = data[1];
			noiseBonus = data[2];
			noiseMax = data[3];
			noisePercentage = data[4];
			break;
		case SUB_ATTRIBUTES.EQUIP_TIME:
			reloadActual = data[0];
			reloadBase = data[1];
			reloadBonus = data[2];
			reloadMax = data[3];
			reloadPercentage = data[4];
			break;
		case SUB_ATTRIBUTES.STAMINA:
			staminaActual = data[0];
			staminaBase = data[1];
			staminaBonus = data[2];
			staminaMax = data[3];
			staminaPercentage = data[4];
			break;
		}
	}
	public string[] GetEquippedPerks(){
		return perks;	
	}
	public void SetPerks(List<Perks.Perk> equippedPerks){
		perks = new string[equippedPerks.Count];
		for (int i=0; i<equippedPerks.Count; i++){
			perks[i] = equippedPerks[i].GetName();
		}
	/*	if (equippedPerks.Contains(Perks.Perk.GetPerk(Perks.AllTerrain.Name) ) )
			allTerrain = true;
		if (equippedPerks.Contains(Perks.Perk.GetPerk(Perks.BackpackIncrease.Name) ) )
			backPackIncrease = true;
		if (equippedPerks.Contains(Perks.Perk.GetPerk(Perks.BackpackIncreasePlus.Name) ) )
			backPackIncreasePlus = true;
		if (equippedPerks.Contains(Perks.Perk.GetPerk(Perks.Disguise.Name) ) )
			disguise = true;
		if (equippedPerks.Contains(Perks.Perk.GetPerk(Perks.DoubleStamina.Name) ) )
			doubleStamina = true;
		if (equippedPerks.Contains(Perks.Perk.GetPerk(Perks.FastManeuvers.Name) ) )
			fastManeuvers  = true;
		if (equippedPerks.Contains(Perks.Perk.GetPerk(Perks.HandgunSilencer.Name) ) )
			handgunSilencer = true;
		if (equippedPerks.Contains(Perks.Perk.GetPerk(Perks.ShotgunProficiency.Name) ) )
			shotgunProficiency = true;
		if (equippedPerks.Contains(Perks.Perk.GetPerk(Perks.SilentAssassin.Name) ) )
			silentAssasin = true;
		if (equippedPerks.Contains(Perks.Perk.GetPerk(Perks.SniperProficiency.Name) ) )
			sniperProficiency = true;
		if (equippedPerks.Contains(Perks.Perk.GetPerk(Perks.TransportBodies.Name) ) )
			transportBodies = true;
	*/
		
	}
	
	public float[] GetAttributeData(ATTRIBUTES attribute){
		switch(attribute){
		case ATTRIBUTES.AGILITY:
			return new float[3]{agilityBase,agilityBonus,agilityPercentage};
			break;
		case ATTRIBUTES.STRENGTH:
			return new float[3]{strengthBase,strengthBonus,strengthPercentage};
			break;
		case ATTRIBUTES.CONSTITUTION:
			return new float[3]{constitutionBase,constitutionBonus,constitutionPercentage};
			break;
		case ATTRIBUTES.DEXTERITY:
			return new float[3]{dexterityBase,dexterityBonus,dexterityPercentage};
			break;
		case ATTRIBUTES.TECHNIQUE:
			return new float[3]{techniqueBase,techniqueBonus,techniquePercentage};
			break;
		}
		return null;
	}
	public float[] GetSubAttributeData(SUB_ATTRIBUTES subAtt){
		switch(subAtt){
		case SUB_ATTRIBUTES.HIT_POINTS:
			return new float[5]{HPActual,HPBase,HPBonus,HPMax,HPPercentage};
			break;
		case SUB_ATTRIBUTES.INVENTORY_SLOTS:
			return new float[5]{inventorySlotsActual,inventorySlotsBase,
			inventorySlotsBonus,inventorySlotsMax,inventorySlotsPercentage};
			break;
		case SUB_ATTRIBUTES.MOVEMENT_SPEED:
			return new float[5]{speedActual,speedBase,
			speedBonus,speedMax,speedPercentage};
			break;
		case SUB_ATTRIBUTES.NOISE_FACTOR:
			return new float[5]{noiseActual,noiseBase,
			noiseBonus,noiseMax,noisePercentage};
			break;
		case SUB_ATTRIBUTES.EQUIP_TIME:
			return new float[5]{reloadActual,reloadBase,
			reloadBonus,reloadMax,reloadPercentage};
			break;
		case SUB_ATTRIBUTES.STAMINA:
			return new float[5]{staminaActual,staminaBase,
			staminaBonus,staminaMax,staminaPercentage};
			break;
		}
		return null;
	}
	public int GetAttributePoints(){ return this.availableAttributePoints;}
}
